package com.cgt.spring.test.proxy;

import com.cgt.spring.service.IBanjiService;
import com.cgt.spring.service.impl.BanjiServiceImpl;
import org.junit.Test;

public class ProxyDemo {
	public static void main(String[] args) {
		DongShiZhang dongShiZhang = new DongShiZhang();
		IQianzi miShu = new MiShu(dongShiZhang);
		miShu.qianzi();
	}

	@Test
	public void test1() {
		DongShiZhang dongShiZhang = new DongShiZhang();
		IQianzi proxy = (IQianzi) ProxyFactory.getProxyInstance(dongShiZhang);
		proxy.qianzi();
	}

	@Test
	public void test2() {
		IBanjiService banjiService = new BanjiServiceImpl();
		IBanjiService proxy = (IBanjiService) ProxyFactory.getProxyInstance(banjiService);
		proxy.selectAll();
		proxy.deleteById(1);
	}
}

